Class Fact

java.lang.Object
edu.uky.ai.lp.logic.Fact
All Implemented Interfaces:
Expression, Formula

public class Fact
extends java.lang.Object
implements Expression
A fact is an individual atomic logical statement in function-free predicate logic.
Author:
Stephen G. Ware
  • Field Summary

    Fields 
    Modifier and Type Field Description
    java.lang.String predicate
    The predicate
    Term[] terms
    The terms to which the predicate applies
  • Constructor Summary

    Constructors 
    Constructor Description
    Fact​(java.lang.String predicate, Term... terms)
    Constructs a new fact with the given predicate and terms.
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(java.lang.Object other)  
    Fact substitute​(Unifier unifier)
    Return a version of this formula with its variables replaced with the values assigned to them by a unifier.
    java.lang.String toString()  
    Unifier unify​(Formula other, Unifier unifier)
    Unify this formula with another formula, adding to a given unifier as needed to make the two expression the same.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • predicate

      public final java.lang.String predicate
      The predicate
    • terms

      public final Term[] terms
      The terms to which the predicate applies
  • Constructor Details

    • Fact

      public Fact​(java.lang.String predicate, Term... terms)
      Constructs a new fact with the given predicate and terms.
      Parameters:
      predicate - the predicate
      terms - the terms
  • Method Details

    • equals

      public boolean equals​(java.lang.Object other)
      Overrides:
      equals in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • unify

      public Unifier unify​(Formula other, Unifier unifier)
      Description copied from interface: Formula
      Unify this formula with another formula, adding to a given unifier as needed to make the two expression the same. The unifier passed in as an argument will not be modified; the (possibly extended) unifier is be returned by this method.
      Specified by:
      unify in interface Formula
      Parameters:
      other - the other logical formula to unify with
      unifier - the unifier to extend
      Returns:
      the new unifier that makes the two formulas the same, or null if they cannot unify
    • substitute

      public Fact substitute​(Unifier unifier)
      Description copied from interface: Formula
      Return a version of this formula with its variables replaced with the values assigned to them by a unifier.
      Specified by:
      substitute in interface Expression
      Specified by:
      substitute in interface Formula
      Parameters:
      unifier - the unifier
      Returns:
      the formula with variables replaced